package com.woniuxy.owner.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.common.dto.OwnerDto;
import com.woniuxy.owner.pojo.OwnerFamily;
import com.woniuxy.owner.service.OwnerFamilyService;
import com.woniuxy.owner.mapper.OwnerFamilyMapper;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

import static com.woniuxy.common.utils.UserUtil.getUser1;

/**
* @author 76540
* @description 针对表【owner_family】的数据库操作Service实现
* @createDate 2025-07-17 17:06:17
*/
@Service
public class OwnerFamilyServiceImpl extends ServiceImpl<OwnerFamilyMapper, OwnerFamily>
    implements OwnerFamilyService{

    @Override
    public List<OwnerFamily> family() {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = attributes.getRequest();
        // 从Authorization头中获取Token
        String token = request.getHeader("Authorization");
        OwnerDto user = getUser1(token);
        return lambdaQuery().eq(OwnerFamily::getOwnerId, user.getId()).list();
    }
}




